<?php

	$sport = new Sport($_POST['sport']);

	// creation de la date
	$date = date("Y-m-d", mktime(0, 0, 0, date("m"), date("d")+intval($_POST['date']),   date("Y")));
	
	$events = $sport->getEventsByDate($date);
	
	$currentLeague = null;
	foreach($events as $_event){
	
		$_event = new Event($_event->id);
		$_eventDate = $_event->getDate();
		$_eventLeague = $_event->getLeague();

		
		// creation des titres 'league'
		if($_eventLeague->getId() != $currentLeague){
			$currentLeague = $_eventLeague->getId();
			
			if($_eventLeague->getCountBetsAvailableForDate($_eventDate) > 0){
			?>
			<div class='div_league '>
				<div class='ft_12 bg_ec p_5 clear fl'><?php echo $_eventLeague->getName("EN"); ?></div>
				<ul class='roll  fl'>
				<?php 
					$_leagueEvents = $_eventLeague->getEvents($_eventDate);
					foreach($_leagueEvents as $_leagueEvent){
						$_leagueEvent = new Event($_leagueEvent->id);
						?>
						<li><?php echo $_leagueEvent->getHour(); ?> - <?php echo $_leagueEvent->getName(); ?><span class="tiptip icon_20 eventDetailsArrows action fr" action='getEventDetails' eventID='<?php echo $_leagueEvent->getId(); ?>' title="Afficher/Cacher les détails du match"></span></li>
						<?php
					}
				?>
				</ul>
			</div>
			<?php
			}	
		}
	}